package com.ge.demo.restfulws.controller;

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ge.demo.restfulws.Greeting;

@Controller
public class GreetingController {

	private final AtomicLong counter = new AtomicLong();

	@RequestMapping("/greeting")
	public @ResponseBody
	Greeting greeting(
			@RequestParam(value = "name", required = false, defaultValue = "World") String name) {

		return new Greeting(counter.incrementAndGet(), String.format(
				"Hello %s!", name));

	}

}